package cn.goktech.controller;

import cn.goktech.entity.Table;
import cn.goktech.service.IDBInfo;
import cn.goktech.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName DBController
 * @Discription 获取数据库信息表
 * @Author Carter
 * @Date 2021/4/18 11:02
 * @Version 1.0
 **/
@RestController
@RequestMapping("/db")
@Api("获取数据库相关信息")
public class DBController {

    @Autowired
    private IDBInfo dbInfo;

    @ApiOperation("获取所有数据库名")
    @GetMapping("/allDataBase")
    public ResultUtil getAllDataBase(){
        return ResultUtil.ok().data("allItem",dbInfo.getAllDataBase());
    }

    @ApiOperation("根据指定数据库名获取指定数据库表信息")
    @GetMapping("/allTableInfo/{dbname}")
    public ResultUtil getAllTableInfo(@ApiParam("指定的数据库名") @PathVariable String dbname){
        return ResultUtil.ok().data("item",dbInfo.getTableByDBName(dbname));
    }

}
